package com.hkbigdata.springbootdemo.mapper;

import com.hkbigdata.springbootdemo.bean.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author liuanbo
 * @creat 2024-11-06-0:25
 * @see 2194550857@qq.com
 */
@Mapper
public interface EmployeeMapper {
    //查询所有员工
    @Select("select * from employee")
    List<Employee> getAll();

    //根据单个查询员工
    @Select("select * from employee where id = #{id}")
    Employee getOne(Integer id);

    //添加员工
    //@Insert("insert into employee (lastName,email,gender) values (#{lastName},#{email},#{gender}")
    @Insert("insert into employee (lastName,gender,email) values ( #{lastName}, #{gender}, #{email})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void add(Employee employee);

    //删除员工
    @Delete("delete from employee where id = #{id}")
    void delete(Integer id);

    //修改员工
    @Update("update employee set lastName = #{lastName},email = #{email},gender = #{gender} where id = #{id}")
    void update(Employee employee);

}
